package mjc.egg;
import mjc.tds.*;
import mjc.type.*;
import mjc.gc.*;
import mjc.compiler.*;
import java.util.*;
import mg.egg.eggc.compiler.libjava.lex.*;
import mg.egg.eggc.compiler.libjava.*;
import mg.egg.eggc.compiler.libjava.problem.IProblem;
import java.util.Vector;
import java.util.List;
import java.util.ArrayList;
public class S_Q_MJAVA implements IDstNode {
LEX_MJAVA scanner;
  S_Q_MJAVA() {
    }
  S_Q_MJAVA(LEX_MJAVA scanner) {
    this.scanner = scanner;
    offset = 0;
    length = 0;
    this.att_scanner = scanner;
    }
int [] sync= new int[0];
  String att_code;
  VAR att_var;
  DTYPE att_type;
  DTYPE att_typh;
  TDS att_tds;
  TAM att_cpu;
  LEX_MJAVA att_scanner;
  String att_nom;
  LinkedList<TDS> att_tdsi;
  private void regle74() throws Exception {
 offset = scanner.getOffset(0);

    //declaration
    //appel
      action_code42_74();
   length = 0; offset = scanner.getPreviousOffset();  }
  private void regle76() throws Exception {
 offset = scanner.getOffset(0);

    //declaration
    T_MJAVA x_2 = new T_MJAVA(scanner ) ;
    S_ARGS_MJAVA x_3 = new S_ARGS_MJAVA(scanner) ;
    T_MJAVA x_4 = new T_MJAVA(scanner ) ;
    S_Q_MJAVA x_6 = new S_Q_MJAVA(scanner) ;
    //appel
      action_auto_inh_76(x_3, x_6);
    x_2.analyser(LEX_MJAVA.token_paro);
      addChild(x_2);
    x_3.analyser() ;
      addChild(x_3);
    x_4.analyser(LEX_MJAVA.token_parf);
      addChild(x_4);
      action_acces_76(x_3, x_6);
    x_6.analyser() ;
      addChild(x_6);
      action_code44_76(x_3, x_6);
     length =x_6.getOffset() + x_6.getLength()  -offset;
  }
  private void regle75() throws Exception {
 offset = scanner.getOffset(0);

    //declaration
    T_MJAVA x_2 = new T_MJAVA(scanner ) ;
    T_MJAVA x_3 = new T_MJAVA(scanner ) ;
    S_Q_MJAVA x_5 = new S_Q_MJAVA(scanner) ;
    //appel
      action_auto_inh_75(x_3, x_5);
    x_2.analyser(LEX_MJAVA.token_pt);
      addChild(x_2);
    x_3.analyser(LEX_MJAVA.token_ident);
      addChild(x_3);
      action_var_75(x_3, x_5);
    x_5.analyser() ;
      addChild(x_5);
      action_code43_75(x_3, x_5);
     length =x_5.getOffset() + x_5.getLength()  -offset;
  }
private void action_code43_75(T_MJAVA x_3, S_Q_MJAVA x_5) throws Exception {
try {
// instructions
this.att_code=x_5.att_code+this.att_cpu.appelFonction(x_3.att_txt);
this.att_type=x_5.att_type;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_auto_inh_76(S_ARGS_MJAVA x_3, S_Q_MJAVA x_6) throws Exception {
try {
// instructions
x_3.att_tds=this.att_tds;
x_6.att_tds=this.att_tds;
x_3.att_tdsi=this.att_tdsi;
x_6.att_tdsi=this.att_tdsi;
x_3.att_cpu=this.att_cpu;
x_6.att_cpu=this.att_cpu;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_acces_76(S_ARGS_MJAVA x_3, S_Q_MJAVA x_6) throws Exception {
try {
// locales
INFO loc_i;
String loc_signature;
TDS loc_tdsh;
// instructions
if (this.att_typh.estTypePrimitif()){
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMJAVAMessages.id_B_12, MJAVAMessages.B_12,new Object[]{});

}

if (this.att_nom==null){
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMJAVAMessages.id_S_01, MJAVAMessages.S_01,new Object[]{});

}
else {
loc_tdsh=this.att_tds.getTDSType(this.att_typh);
loc_signature=loc_tdsh.getSignature(this.att_typh.getNom(), this.att_nom, x_3.att_typeargs);
loc_i=loc_tdsh.chercherGlobalement(loc_signature);
if (loc_i==null){
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMJAVAMessages.id_B_11, MJAVAMessages.B_11,new Object[]{""+loc_signature});

}
else {
x_6.att_nom=null;
x_6.att_typh=loc_i.getType();
}
}
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_code44_76(S_ARGS_MJAVA x_3, S_Q_MJAVA x_6) throws Exception {
try {
// instructions
this.att_code=x_3.att_code+x_6.att_code;
this.att_type=x_6.att_type;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_var_75(T_MJAVA x_3, S_Q_MJAVA x_5) throws Exception {
try {
// locales
INFO loc_i;
TDS loc_tdsh;
// instructions
if (this.att_typh.estTypePrimitif()){
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMJAVAMessages.id_B_12, MJAVAMessages.B_12,new Object[]{});

}

if (this.att_nom==null){
x_5.att_typh=this.att_typh;
x_5.att_nom=x_3.att_txt;
}
else {
loc_tdsh=this.att_tds.getTDSType(this.att_typh);
loc_i=loc_tdsh.chercherLocalement(this.att_nom);
if (loc_i==null){
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMJAVAMessages.id_B_09, MJAVAMessages.B_09,new Object[]{""+this.att_nom, ""+loc_tdsh.getNom()});

}
else {
x_5.att_typh=loc_i.getType();
x_5.att_nom=x_3.att_txt;
}
}
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_auto_inh_75(T_MJAVA x_3, S_Q_MJAVA x_5) throws Exception {
try {
// instructions
x_5.att_tds=this.att_tds;
x_5.att_tdsi=this.att_tdsi;
x_5.att_cpu=this.att_cpu;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_code42_74() throws Exception {
try {
// locales
INFO loc_i;
TDS loc_tdsh;
// instructions
if (this.att_nom==null){
this.att_var=null;
}
else {
loc_tdsh=this.att_tds.getTDSType(this.att_typh);
loc_i=loc_tdsh.chercherLocalement(this.att_nom);
if (loc_i==null){
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMJAVAMessages.id_B_09, MJAVAMessages.B_09,new Object[]{""+this.att_nom, ""+loc_tdsh.getNom()});

}
else {
if (loc_i instanceof VAR ){
this.att_var=((VAR)loc_i);
}

}
}
this.att_code="";
this.att_type=this.att_typh;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
  public void analyser () throws Exception {
    scanner.lit ( 1 ) ;
    switch ( scanner.fenetre[0].code ) {
      case LEX_MJAVA.token_mult : // 45480
        regle74 () ;
      break ;
      case LEX_MJAVA.token_div : // 45481
        regle74 () ;
      break ;
      case LEX_MJAVA.token_mod : // 45482
        regle74 () ;
      break ;
      case LEX_MJAVA.token_et : // 45483
        regle74 () ;
      break ;
      case LEX_MJAVA.token_plus : // 45477
        regle74 () ;
      break ;
      case LEX_MJAVA.token_moins : // 45478
        regle74 () ;
      break ;
      case LEX_MJAVA.token_ou : // 45479
        regle74 () ;
      break ;
      case LEX_MJAVA.token_inf : // 45471
        regle74 () ;
      break ;
      case LEX_MJAVA.token_infeg : // 45472
        regle74 () ;
      break ;
      case LEX_MJAVA.token_sup : // 45473
        regle74 () ;
      break ;
      case LEX_MJAVA.token_supeg : // 45474
        regle74 () ;
      break ;
      case LEX_MJAVA.token_eg : // 45475
        regle74 () ;
      break ;
      case LEX_MJAVA.token_neg : // 45476
        regle74 () ;
      break ;
      case LEX_MJAVA.token_affect : // 45455
        regle74 () ;
      break ;
      case LEX_MJAVA.token_virg : // 45452
        regle74 () ;
      break ;
      case LEX_MJAVA.token_pv : // 45453
        regle74 () ;
      break ;
      case LEX_MJAVA.token_parf : // 45447
        regle74 () ;
      break ;
      case LEX_MJAVA.token_pt : // 45454
        regle75 () ;
      break ;
      case LEX_MJAVA.token_paro : // 45446
        regle76 () ;
      break ;
      default :
               scanner._interrompre(IProblem.Syntax, scanner.getBeginLine(), IMJAVAMessages.id_MJAVA_unexpected_token,MJAVAMessages.MJAVA_unexpected_token,new String[]{scanner.fenetre[0].getNom()});
    }
  }
    private IDstNode parent;
    public void setParent( IDstNode p){parent = p;}
    public IDstNode getParent(){return parent;}
    private List<IDstNode> children = null ;
    public void addChild(IDstNode node){
      if (children == null) {
         children = new ArrayList<IDstNode>() ;}
      children.add(node);
      node.setParent(this);
    }
    public List<IDstNode> getChildren(){return children;}
    public boolean isLeaf(){return children == null;}
    public void accept(IDstVisitor visitor) {
      boolean visitChildren = visitor.visit(this);
      if (visitChildren && children != null){
        for(IDstNode node : children){
          node.accept(visitor);
        }
    }
    visitor.endVisit(this);
  }
  private int offset;
  private int length;
  public int getOffset(){return offset;}
  public void setOffset(int o){offset = o;}
  public int getLength(){return length;}
  public void setLength(int l){length = l;}
  private boolean malformed = false;
  public void setMalformed(){malformed = true;}
  public boolean isMalformed(){return malformed;}
  }
